<?php
/*******************************************************************************

    FinalsClub.org is a platform for students and faculty to collaborate
    and share their knowledge with the world.

    Copyright (C) 2009  Andrew Magliozzi
 
    This file is a part of FinalsClub.org.

    FinalsClub.org is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
    To contact FinalsClub.org, send an email to info@finalsclub.org, or
    send mail to Finals Club, c/o Veritas Tutors, 1132 Massachusetts Avenue,
    Cambridge, MA 02138.

*******************************************************************************/

/*
 * Created on Jan 30, 2009
 * Group helper
 * @package: Finalsclub
 * @subpackager: Helpers
 * @author: Colin Hom
 * 
 */
 
function render_group_name($group){
	return link_to($group->getName(),'groups/show?id='.$group->getId());
}


function calculate_days_late($date_time)
{
	$time = strtotime($date_time);
	$difference = time() - $time;
	$days = $difference/(60*60*24);
	
	return floor($days);
	
}

function render_message_time($date_time){
	$today = time();
	$yesterday = time() - 60*60*24;
	
	$message_time = strtotime($date_time);
	
	$today = date("m/d/Y",$today);
	$yesterday = date("m/d/Y",$yesterday);
	$message = date("m/d/Y",$message_time);
	
	$day_time = date("g:i a", $message_time);
	
	if($today == $message)
	{
		return 'Today at '.$day_time;
	}
	elseif($yesterday == $message)
	{
		return 'Yesterday at '.$day_time;
	}
	else
	{
		return $message.' at '.$day_time;
	}	
}

function render_task_due_date($date_time){
	$tomorrow = time() + 60*60*24;
	$task_time = strtotime($date_time);
	
	$tomorrow = date("m/d/Y",$tomorrow);
	$task = date("m/d/Y",$task_time);
	
	
	if($tomorrow == $task)
	{
		return 'tomorrow';
	}
	else
	{
		return $task;
	}	
}

?>
